package com.mpyy.service.everyday;

import com.mpyy.dao.everyday.ProductInfoDao;
import com.mpyy.dao.everyday.ProductTypeDao;
import com.mpyy.pojo.ProductInfo;
import com.mpyy.pojo.Tree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version 1.0
 * @Description
 * Author 商品管理树形控件查询
 * @Date 2022-03-06 21:57
 */
@Service
public class ProductServiceImpl implements ProductServiceInter {
    @Autowired
    private ProductInfoDao productInfoDao;
    @Autowired
    private ProductTypeDao productTypeDao;
    @Override
    public List<ProductInfo> getproId(String proId, int page, int limit) {
        List<ProductInfo> all=null;
        if (proId=="000"){
            all=productInfoDao.all("000",page,limit);
        }else if (Integer.parseInt(proId)%100==0){
            if (Integer.parseInt(proId)==0){
                all=productInfoDao.all("000",page,limit);
            }else {
                all=productInfoDao.second(Integer.parseInt(proId),page,limit);
            }
        }else if (Integer.parseInt(proId)%100!=0){
            all=productInfoDao.tertiary(Integer.parseInt(proId),page,limit);
        }
        return all;
    }

    @Override
    public List<Tree> all() {
        return productTypeDao.all();
    }
}
